<template name="addGroup">
	{{>sAlert}}
	<form name="addGroup" id="addGroup" class="form-horizontal">
		<div class="form-group">
			<label for="groupname" class="control-label col-sm-2">群组名称</label>
			<div class="col-sm-10">
				<input type="text" name="groupname" id="groupname" placeholder="请输入群组名称">
			</div>
		</div>
		<div class="form-group">
			<label for="members" class="control-label col-sm-2">群组成员</label>
			<div class="col-sm-2">
				好友列表<br/>
				<ul>
					{{#each friends}}
					<li class="friends-list" data-id="{{friend.id}}">{{friend.username}}</li>
					{{/each}}
				</ul>
			</div>
			<div class="col-sm-2">
				<button id="add">添加&gt;&gt;</button><br/><br/>
				<button id="del">&lt;&lt;删除</button>
			</div>
			<div class="col-sm-2">
				已选成员<br/>
				<ul>
					<li class="choose-list" data-id={{currentUser._id}}>{{currentUser.username}}</li>
				</ul>
			</div>
		</div>
		<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="submit" name="sub" id="sub" value="创建">
				</div>
		</div>
	</form>
</template>
<template name="grouplist">
	<div class="row">
		<div class="col-xs-6">
			<table class="table table-responsive">
				<thead>
					<tr>
						<th>群组名称</th>
						<th>群组创建者</th>
						<th>群组创建时间</th>
						<th>群组人数</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{{#each grouplists}}
					<tr>
						<td>{{groupname}}</td>
						<td>{{{ownername}}}</td>
						<td>{{dateFormat}}</td>
						<td>{{nums}}</td>
						<td>{{#if isadmin}}<a href="/group/edit/{{_id}}">编辑</a>|<a href="/group/setmanage/{{_id}}">设置管理员</a>|{{/if}}{{#if isowner}}<a href="/group/del/{{_id}}">删除</a>|{{/if}}<a href="/group/chat/{{_id}}">聊天</a></td>
					</tr>
					{{/each}}
				</tbody>
				<tfoot>
					<tr>
						<td colspan="5">
							{{>pagination}}
						</td>
					</tr>
				</tfoot>
			</table>
	</div>
	</div>
</template>
<template name="groupchat">
	{{>sAlert}}
	<div class="row" >
	<div class="form-group col-xs-6" id="chatlogs" style="height:200px;border:1px solid #eeeeee;overflow-y: auto">
		{{#if Template.subscriptionsReady}}
		{{#if logs}}
		{{#each logs}}
		{{#if isowner}}
		<div class="owner"><span style="color:red;">{{fromusername}}</span>:{{{content}}}</div>
		{{else}}
		<div class="person" style="text-align:right"><span style="color:blue;">{{fromusername}}</span>:{{{content}}}</div>
		{{/if}}
		{{/each}}
		{{else}}
		暂无聊天记录
		{{/if}}
		{{/if}}
		</div>
		<div class="form-group col-xs-6" id="groupmembers" style="border:1px solid #eeeeee;overflow-y: auto">
		{{#if Template.subscriptionsReady}}
		{{#each members}}
		{{#if ismember}}
			<div class="member"><span>成员</span>:{{{username}}}</div>
		{{else}}
			{{#if ismanager}}
			<div class="person"><span style="color:red;">管理员</span>:{{{username}}}</div>
			{{else}}
			<div class="person"><span style="color:blue;">群主</span>:{{{username}}}</div>
			{{/if}}
		{{/if}}
		{{/each}}
		{{/if}}
		</div>
	</div>
	<div style="height:5px" class="clearfix"></div>
	<div class="row"  >
		<div class="form-group col-xs-6" style="border:1px solid #000000;padding-top:5px;">
		{{>editor}}
		<!-- <textarea id="message" name="message" placeholder="请输入聊天内容" cols="80" rows="10"></textarea> -->
		<div>
		<button id="send" name="send" class="btn btn-primary">发送</button>
		</div>
		</div>
	</div>
</template>
<template name="groupedit">
	{{>sAlert}}
	<form name="addGroup" id="addGroup" class="form-horizontal">
		<div class="form-group">
			<label for="groupname" class="control-label col-sm-2">群组名称</label>
			<div class="col-sm-10">
				<input type="text" name="groupname" id="groupname" placeholder="请输入群组名称" value="{{group.groupname}}">
			</div>
		</div>
		<div class="form-group">
			<label for="members" class="control-label col-sm-2">群组成员</label>
			<div class="col-sm-2">
				好友列表<br/>
				<ul id="friends-lists">
					{{#each friends}}
					<li class="friends-list" data-id="{{friend.id}}">{{friend.username}}</li>
					{{/each}}
				</ul>
			</div>
			<div class="col-sm-2">
				<button id="add">添加&gt;&gt;</button><br/><br/>
				<button id="del">&lt;&lt;删除</button>
			</div>
			<div class="col-sm-2">
				已选成员<br/>
				<ul id="choose-lists">
					{{#each group.member}}
					<li class="choose-list" data-id="{{id}}">{{username}}</li>
					{{/each}}
				</ul>
			</div>
		</div>
		<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="submit" name="sub" id="sub" value="编辑">
				</div>
		</div>
	</form>
</template>
<template name="groupmanager">
	{{>sAlert}}
	<form name="addGroup" id="addGroup" class="form-horizontal">
		<div class="form-group">
			<label for="members" class="control-label col-sm-2">群组成员列表</label>
			<div class="col-sm-2">
				<ul id="memberlist">
					{{#each group.member}}
					{{#if ismember}}
					<li class="friends-list" data-id="{{id}}">{{username}}</li>
					{{/if}}
					{{/each}}
				</ul>
			</div>
			<div class="col-sm-2">
				<button id="add">添加&gt;&gt;</button><br/><br/>
				<button id="del">&lt;&lt;删除</button>
			</div>
			<div class="col-sm-2">
				已选管理员<br/>
				<ul id="managerlist">
					{{#each group.manager}}
					<li class="choose-list" data-id="{{id}}">{{username}}</li>
					{{/each}}

				</ul>
			</div>
		</div>
		<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="submit" name="sub" id="sub" value="修改">
				</div>
		</div>
	</form>
</template>
